package com.mcgrady.hello;

import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @author McGrady
 */
public class Calculator {
    public static void main(String[] args) {
        System.out.println("欢迎来到计算器");
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println(">>请输入第一个数：");
            int num1 = scanner.nextInt();
            System.out.println(">> 请选择运算法则，输入对应的编号...");
            System.out.println("1.加法\n2.减法\n3.乘法\n4.除法\n5.取余");
            int symbol = scanner.nextInt();
            System.out.println(">>请输入第二个数");
            int num2 = scanner.nextInt();
            Object result = symbol == 1 ? num1 + num2 : symbol == 2 ? num1 - num2 :
                    symbol == 3 ? num1 * num2 : symbol == 4 ? (double) num1 / num2 : symbol == 5 ? num1 % num2 : "符号输入错误！";
            System.out.println("结果为" + result);
        }
    }
}